from drf_haystack.serializers import HaystackSerializer
from rest_framework import serializers

from goods.models import SKU
from goods.search_indexes import SKUIndex


class GoodsSerializers(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = '__all__'


class SKUIndexSerializers(HaystackSerializer):
    object = GoodsSerializers(read_only=True)

    class Meta:
        index_classes = [SKUIndex]
        fields = ('text', 'object')